<template>
  <div class="top">
    <div class="head">
      <div class="h">
        最近最热电影
      </div>
      <div class="r-a">
        <span>TOP250</span>
        <span>最新</span>
        <span>热门</span>
      </div>
    </div>
    <div class="box">
      <div class="swiper-container swiper-container250">
        <div class="swiper-wrapper">
            <div class="swiper-slide" v-for="item in top250.subjects">
              <div class="img">
                <img :src=item.images.medium alt="">
              </div>
              <div class="txt">
                {{item.title}} <strong>{{item.rating.average}}</strong>
              </div>
            </div>
        </div>
        <!-- Add Pagination -->
        <div class="swiper-pagination swiper-pagination250"></div>
      </div>
    </div>
    
  </div>
</template>
<script>
  import Swiper from 'swiper';
  import 'swiper/dist/css/swiper.min.css';
  import qs from 'qs'

  export default {
    name: "top",
    data(){
      return{
          top250:[]
      }
    },
    mounted(){
      var swiper250 = new Swiper('.swiper-container250', {
          pagination: '.swiper-pagination250',
          slidesPerView: 6,
          slidesPerColumn: 2,
          paginationClickable: true,
          spaceBetween: 30,
          observer:true,
          observeParents:true,
          loop: true
      });
      
    },
    created(){
        this.$http.get("/api/movie/top250",{
          params:{
              "start": 0,
              "count": 50
          }
        })
        .then(res => {
          
          this.top250 = res.data;
          console.log(this.top250)
        })
        .catch(error => {
          console.log(error)
        });
        //重新计算slides个数
      }
  }
</script>
<style scoped>
  .top{
    width: 100%;
    margin: 20px 0;
  }
  .top .head{
    width: 100%;
    height: 40px;
    border-bottom: 1px solid #d6d6d6;
    margin-top: 10px;
  }
  .top .head .h{
    font-size: 16px;
    color: #333;
    line-height: 40px;
    float: left;
  }
  .r-a{
    float: left;
    margin-left: 20px;
  }
  .r-a span{
    font-size: 14px;
    color: #666;
    line-height: 40px;
    padding: 0 14px;
    cursor: pointer;
  }
  .box{
    width: 100%;
    height: 600px;
    margin-top: 20px;
  }
  .box .swiper-container250{
    width: 100%;
    height: 100%;
  }
  .box .swiper-container250 .swiper-slide{
    height: 270px;
  }
  .box .swiper-container250 .swiper-slide .img{
    width: 100%;
    height: 220px;
  }
  .box .swiper-container250 .swiper-slide .img img{
    display: block;
    width: 100%;
    height: 100%;
  }
  .box .swiper-container250 .swiper-slide .txt{
      width: 100%;
      height: 50px;
      font-size: 14px;
      line-height: 24px;
  }
  .box .swiper-container250 .swiper-slide .txt strong{
      font-weight: normal;
      color: #e09015;
      padding-left: 4px;
  }
</style>